package com.game.object;

import org.andengine.engine.camera.Camera;
import org.andengine.extension.physics.box2d.PhysicsWorld;
import org.andengine.opengl.texture.region.ITiledTextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import com.badlogic.gdx.math.Vector2;

public abstract class Programmer extends GameObject {

	private static final long[] PLAYER_ANIMATE = new long[] { 100, 100, 100 };
	private OnDieScreenListener onDieScreenListener;
	
	
	public Programmer(float pX, float pY, ITiledTextureRegion texture, VertexBufferObjectManager vbo,
			Camera camera, PhysicsWorld physicsWorld) {
		super(pX, pY, texture, vbo, camera, physicsWorld);
	}
	
	
	public void setOnMuerteListener(OnDieScreenListener onDieScreenListener)
	{
		this.onDieScreenListener = onDieScreenListener;
	}
	
	public void moverEjeX_Izquierda()
	{
		animate(PLAYER_ANIMATE, 0, 2, true);
		getBody().setLinearVelocity(new Vector2(-5f,0));
	}
	
	public void moverEjeX_Derecha()
	{
		animate(PLAYER_ANIMATE, 0, 2, true);
		getBody().setLinearVelocity(new Vector2(5f,0));
	}
	@Override
	public void jump()
	{
		animate(PLAYER_ANIMATE, 0, 2, true);
		getBody().setLinearVelocity(new Vector2(getBody().getLinearVelocity().x, 12)); 
		
	}
	
	@Override
	public void murioEnPantalla()
	{
		if(this.getY() <=0 )
		{
			if(onDieScreenListener != null)
			{
				onDieScreenListener.onDie(this);
			}
		}
		
	}

	

}
